package com.hanter.android.radui.mvvm

import android.os.Bundle
import android.view.View
import com.hanter.android.radlib.util.WindowUtils
import com.hanter.android.radui.R
import com.hanter.android.radui.mvp.TitleBarHelper
import com.hanter.android.radwidget.statusbar.StatusBarHelper

abstract class MvvmTitleBarActivity : BaseMvvmActivity() {

    lateinit var titleBarHelper: TitleBarHelper

    override fun onCreate(savedInstanceState: Bundle?) {
        WindowUtils.setTranslucentStatus(this, true)
        StatusBarHelper.setStatusBarMode(this, true)
        super.onCreate(savedInstanceState)
        initTitleBar()
    }

    protected open fun initTitleBar() {
        titleBarHelper = TitleBarHelper(this)
        titleBarHelper.initTitleBar()
        titleBarHelper.leftBarButton.setOnClickListener(this)
    }

    override fun onClick(v: View?) {
        when (v?.id) {

            R.id.leftBarButton -> {
                onBackPressed()
            }

            else -> super.onClick(v)
        }
    }

}
